package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.weixing.mall.provider.api.model.vo.ItemVo;
import com.weixing.mall.provider.api.service.ItemFeign;
import com.weixing.mall.provider.model.domain.OrderBinding;
import com.weixing.mall.provider.model.vo.OrderDetilVo;
import com.weixing.mall.provider.service.IOrderBindingService;
import com.weixing.mall.provider.service.IOrderFrontService;
import com.weixing.mall.provider.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class OrderFrontServiceImpl implements IOrderFrontService {

    @Autowired
    private IOrderService orderService;
    @Autowired
    private IOrderBindingService orderBindingService;

    @Autowired
    private ItemFeign itemFeign;
    @Override
    public Map<String, Object> scanCode(String scanCode) {
        String [] ss=scanCode.split("_");
        String productSn=ss[1];
        ItemVo vo=itemFeign.findProductVoByProductSn(productSn).getData();
        OrderBinding binding=orderBindingService.getOne(new QueryWrapper<OrderBinding>().eq("commodity_code",ss[0]));
        Long orderId=binding.getOrderId();
        OrderDetilVo orderDetilVo=orderService.selectOrderDetails(orderId);
        Map<String,Object> tt=new HashMap<String, Object>();
        tt.put("itemVo",vo);
        tt.put("orderDetil",orderDetilVo);
        return tt;
    }
}
